﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Xml;

public partial class ws_Catalog_BIShops : WSPageBase
{

    #region Page Events

    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);
        // Enabled trace in code
        // this.Context.Trace.IsEnabled = false;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        XmlDocument xReturn = getXML();
        Response.ContentType = "text/xml";
        Response.Write(xReturn.OuterXml);
    }

    #endregion

    public XmlDocument getXML()
    {

        XmlDocument xReturn = new XmlDocument();
        DataTable tbl = new DataTable("tbl");
        Exception err = new Ko2.DB.BI.Catalogs.Shops().Get(ref tbl, Year, Month, Day);
        if (err != null)
        {
            DateTime dt = new DateTime(Year, Month, Day);
            dt = dt.AddDays(-1);
            tbl = new DataTable("tbl");
            err = new Ko2.DB.BI.Catalogs.Shops().Get(ref tbl, dt.Year, dt.Month, dt.Day);
            if (err != null)
            {
                dt = dt.AddDays(-1);
                tbl = new DataTable("tbl");
                err = new Ko2.DB.BI.Catalogs.Shops().Get(ref tbl, dt.Year, dt.Month, dt.Day);
            }
            if (err != null)
            {
                dt = dt.AddDays(-1);
                tbl = new DataTable("tbl");
                err = new Ko2.DB.BI.Catalogs.Shops().Get(ref tbl, dt.Year, dt.Month, dt.Day);
            }
        }
        if (err == null)
        {
            DataView v = tbl.DefaultView;
            v.Sort = "Name";
        }
        err = MakeXML(ref xReturn, ref tbl, ref err);

        return xReturn;
    }

}
